//
//  MJPhotoBrowser+MyPhoto.m
//  WestWolves
//
//  Created by JL on 16/2/29.
//  Copyright © 2016年 ZJ. All rights reserved.
//

#import "MJPhotoBrowser+MyPhoto.h"

@implementation MJPhotoBrowser (MyPhoto)
+(void)showMyMJPhotoBrowserWithImaURLArray:(NSArray *)imaArray andImaView:(UIImageView *)imaView andIndex:(int)index
{
    NSMutableArray *_urls=[[NSMutableArray alloc] init];
    for (int i=0;i<imaArray.count;i++) {
        NSString *imaPic=imaArray[i];
        [_urls addObject:imaPic];
    }
    int count = (int)_urls.count;
    // 1.封装图片数据
    NSMutableArray *photos = [NSMutableArray arrayWithCapacity:count];
    for (int i = 0; i<count; i++) {
        // 替换为中等尺寸图片
        NSString *url = [_urls[i] stringByReplacingOccurrencesOfString:@"thumbnail" withString:@"bmiddle"];
        MJPhoto *photo = [[MJPhoto alloc] init];
        photo.url = [NSURL URLWithString:url]; // 图片路径
        //photo.srcImageView = imaView; // 来源于哪个UIImageView
        
        [photos addObject:photo];
    }
    // 2.显示相册
    MJPhotoBrowser *browser = [[MJPhotoBrowser alloc] init];
    browser.currentPhotoIndex = index; // 弹出相册时显示的第一张图片是？
    browser.photos = photos; // 设置所有的图片
    [browser show];
}
+(void)showMyMJPhotoBrowserWithImaArray:(NSArray *)imaArray andImaView:(UIImageView *)imaView andIndex:(int)index
{
    NSMutableArray *imasArray=[[NSMutableArray alloc] init];
    for (int i=0;i<imaArray.count;i++) {
        NSString *imaPic=imaArray[i];
        [imasArray addObject:imaPic];
    }
    int count = (int)imasArray.count;
    // 1.封装图片数据
    NSMutableArray *photos = [NSMutableArray arrayWithCapacity:count];
    for (int i = 0; i<count; i++) {
        // 替换为中等尺寸图
        MJPhoto *photo = [[MJPhoto alloc] init];
        photo.image = imasArray[i]; // 图片路径
        photo.srcImageView = imaView; // 来源于哪个UIImageView
        [photos addObject:photo];
    }
    // 2.显示相册
    MJPhotoBrowser *browser = [[MJPhotoBrowser alloc] init];
    browser.currentPhotoIndex = index; // 弹出相册时显示的第一张图片是？
    browser.photos = photos; // 设置所有的图片
    [browser show];
}
@end
